package com.yao.club.controller.goods;


import com.yao.club.entity.dto.*;
import com.yao.club.entity.result.ResponseEntity;
import com.yao.club.entity.result.ResultEntity;
import com.yao.club.entity.vo.MallGroupVO;
import com.yao.club.entity.request.MallGoodsSearchRequest;
import com.yao.club.entity.vo.MallSearchSuggestionVO;
import com.yao.club.entity.vo.GoodsDetailVO;
import com.yao.club.service.MallHomeService;
import com.yao.club.service.MallSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;


@Api(tags = "俱乐部商城-搜索模块")
@RestController
@RequestMapping("/mall/mallSearch")
public class MallSearchController {
    @Autowired
    private MallSearchService mallSearchService;
    /**
     * 获得热门搜索推荐
     */
    @ApiOperation(value = "获得热门搜索推荐")
    @GetMapping("/goodsHotSearchList")
    ResponseEntity<List<MallHotWords>> goodsHotSearchList(){
        return mallSearchService.getHotWords();
    }


    /**
     * 根据关键字搜索品牌
     */
    @ApiOperation(value = "根据关键字搜索品牌")
    @PostMapping("/mallGoodsListPageCondition")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "String", name = "keyword", value = "关键字", required = true),
    })
    ResponseEntity<List<GoodsBrand>> mallGoodsListPageCondition(String keyword){
        return mallSearchService.getBrandsByKeyWords(keyword);
    }
    /**
     * 查询所有品牌
     */
    @ApiOperation(value = "查询所有品牌")
    @GetMapping("/mallGoodsListAllCondition")
    ResponseEntity<List<GoodsBrand>> mallGoodsListAllCondition(){
        return mallSearchService.mallGoodsListAllCondition();
    }

    /**
     * 根据关键字搜索建议提示
     * @param keyword
     * @return
     */
    @ApiOperation(value = "根据关键字搜索建议提示")
    @PostMapping("/goodsSearchKeywordList")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "String", name = "keyword", value = "关键字", required = true),
    })
    ResponseEntity<List<MallSearchSuggestionVO>> goodsSearchKeywordList(String keyword){
        return mallSearchService.goodsSearchKeywordList(keyword);
    }

    /**
     *  根据(排序字段(soldNumSort/newGoodsSort/priceSort)搜索商品字段
     * @param request
     * @return
     */
    @ApiOperation(value = "搜索商品")
    @PostMapping("/searchGoods")
    public ResponseEntity<ResultEntity<MallGoodsInfo>> searchGoods(@RequestBody MallGoodsSearchRequest request) {
        return mallSearchService.searchGoods(request);
    }

}
